package com.jichaoyun.sys.controller;


import com.jichaoyun.common.model.PagedResult;
import com.jichaoyun.common.model.Result;
import com.jichaoyun.model.vo.UpdownLimitVo;

import com.jichaoyun.sys.service.UpdownLimitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = {"上下限设置接口"})
@RequestMapping("/sys/updownlimit")
public class UpDownLimitController {

    @Autowired
    private UpdownLimitService updownLimitService;

    @ApiOperation("启用时间记录查询-查询所有的用户")
    @GetMapping("/pageSelectAll")
    public Result<PagedResult> pageSelectAll(Integer pageNo){

        PagedResult  pagedResult =  updownLimitService.pageSelectAll(pageNo);
        return Result.success(pagedResult);
    }

    @ApiOperation("启用时间记录查询-查询某个用户")
    @GetMapping("/pageSelectOne")
    public Result<PagedResult> pageSelectOne(Integer pageNo,Integer stationNo){

        PagedResult  pagedResult =  updownLimitService.pageSelectOne(pageNo,stationNo);
        return Result.success(pagedResult);
    }

    @ApiOperation("上下限设置--回显查询")
    @GetMapping("/limitPageReg")
    public Result<PagedResult> limitPageReg(Integer pageNo){

        PagedResult  pagedResult =  updownLimitService.pageSelectReg(pageNo);
        return Result.success(pagedResult);
    }

    @ApiOperation("上下限设置--单个站点的启用")
    @PostMapping("/setOneStation")
    public Result<?> setOneStation(@RequestBody UpdownLimitVo updownLimitVo){
        updownLimitService.setOneStation(updownLimitVo);
        return Result.success("启动成功");
    }


    @ApiOperation("上下限设置--多个站点的启用")
    @PostMapping("/setStations")
    public Result<?> setStations(@RequestBody List<UpdownLimitVo> updownLimitVos){
        updownLimitService.setStations(updownLimitVos);
        return Result.success("启动成功");
    }

}
